﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void PrintNumbers(int[] numbers)
    {
        Console.Write("{ ");
        foreach (int number in numbers)
        {
            Console.Write("{0} ", number);
        }
        Console.WriteLine("}");
    }


    static int? FindNumberOrLess(int[] numbers, int numberK)
    {
        if (numberK > numbers[numbers.Length - 1])
        {
            return null;
        }

        for (int i = numberK; i >= 0; i--)
        {
            if (Array.BinarySearch(numbers, i) >= 0)
            {
                return i;
            }
            numberK--;
        }
        return null;
    }

    static void Main()
    {
        int[] numbers = { 5, 7, 12, 3, 11, 39, 4, 6, 9, 23, 15 };
        Array.Sort(numbers);
        PrintNumbers(numbers);
        Console.WriteLine("Enter number to search for: ");
        int numberK = int.Parse(Console.ReadLine());
        int? number = FindNumberOrLess(numbers, numberK);
        if (number != null)
        {
            Console.WriteLine(number);
        }
        else
        {
            Console.WriteLine("Not a number.");
        }
    }
}
